#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

#include <stdio.h>
int main()
{
	int a[] = { 1,2,3,1,1,2,2 };
	int length = sizeof(a) / sizeof(a[1]);
	int conter = 1;
	for (int i = 0; i < length ; i++)
	{
		for (int j = length; j > 0; j--)
		{
			if (a[i] == a[j])
			{
				conter++;
				int t = a[j];
				printf("%d ", t);
			}
			else
			{
				conter = 1;
			}
		}
	}
}